package com.tuyrt.`as`.proj.common.ui.component

import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment

/**
 * author: Administrator on 2021/4/29.
 * desc:
 */
abstract class HiBaseFragment : Fragment() {

    @JvmField
    protected var layoutView: View? = null

    @LayoutRes
    abstract fun getLayoutId(): Int

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        layoutView = inflater.inflate(getLayoutId(), container, false)
        return layoutView
    }

    fun toast(message: String?) {
        if (!TextUtils.isEmpty(message)) {
            Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
        }
    }

    // 页面是否还在
    val isAlive: Boolean
        get() = !(isRemoving || isDetached || activity == null)


}